//
//  DebugLogViewController.m
//  YK_DebugManager
//
//  Created by edward on 2021/1/13.
//

#import "DebugLogViewController.h"



@interface DebugLogViewController ()<UITextViewDelegate>

@property(nonatomic,strong) UITextView *textView;
@end

@implementation DebugLogViewController


- (instancetype)initWithDissMissBlock:(void (^)(void))dissMissBlock
{
    if (self = [super initWithDissMissBlock:dissMissBlock]) {
        self.title = @"日志记录";
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupUI];
}

- (void)setupUI
{
//    [self.view addSubview:self.textView];
    [self addCustomView:self.textView];
}
- (UITextView *)textView
{
    if(!_textView)
    {
        _textView = [[UITextView alloc] initWithFrame:self.safeView.bounds];
        _textView.scrollEnabled = YES;
        _textView.backgroundColor = UIColor.clearColor;
        _textView.font = [UIFont systemFontOfSize:14];
        _textView.textColor = [UIColor.blackColor colorWithAlphaComponent:0.7];;
        _textView.editable = NO;
        _textView.delegate = self;
    }
    return _textView;
}
- (void)dissMiss
{
    [super dissMiss];
}
- (void)funcClick
{
    [super funcClick];
    [self clearText];
}
- (void)addLogText:(NSString *)text
{
    self.textView.text = [self.textView.text stringByAppendingFormat:@"\r\n%@",text];
    [self changeLine];
}
- (void)clearText
{
    self.textView.text = @"";
    [self changeLine];
}

- (void)changeLine
{
    [self.textView scrollRangeToVisible:NSMakeRange(self.textView.text.length - 1, 1)];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
